rm(list = ls())

library(fixest)
library(tidyverse)

dict = c(vote_yes = 'Vote for Statute of Limitations Extension (0/1)',
         syn_in_gem_bin = 'Synagogue: hometown',
         victim_stat = 'MP subset',
         elecper = 'Vote',
         party_fe = 'Party',
         state_id = 'State',
         ags_cluster = 'Municipality/place of birth')

## Load MP data

dat <- readRDS('data/mp_data.rds')  %>%
  filter(vote_abstain_no_show == 0) %>%
  filter(elecper != 8) %>%
  mutate(victim_stat = case_when(nsdap_member == 1 ~ 'NSDAP members',
                                 exile_repressed_combined == 1 ~ 'Victims',
                                 resistance_member == 1 ~ 'Victims',
                                 TRUE ~ 'Bystanders'))

## 

m1 <- feols(vote_yes ~ syn_in_gem_bin | elecper + party_fe + state_id,
            cluster = 'ags_cluster',
            data = dat,
            fsplit = ~ victim_stat)


## Export 

etable(list(m1), 
       dict = dict,
       digits = 4, 
       drop = c("Intercept", "Constant"),
       title = 'Results in different subsets of MPs: NSDAP members, who were most complicit in Nazi violence; victims, defined as MPs who were repressed or in exile; and bystanders, the group that encompasses the remaining MPs.',
       label = 'tab:res_mp_ss',
       digits.stats = 3,
       adjustbox = 1, 
       fitstat = ~ r2 + n,
       tex = T) 


